﻿
#ifndef _GAME_LOGIC_H_
#define _GAME_LOGIC_H_

#include "game_msg.h"
#include "../share/common_singleton.h"
#include "../share/jsonmessage.h"
#include "Player.h"
#include "../share/proxy_head.h"
#include "../share/timer.h"


class CPlayerCountReportTimer : public ::common::CTimer
{
public:
	virtual void TimerActive();
};


class CGameLogic :public common::CSingleton<CGameLogic>
{
public:
	CGameLogic(){}
	~CGameLogic(){}
public:
	void Initialize();
public:
	static void SWildDigOperation(Player& player, const CJsonMessageBase& msg);
	static void SUpdateOfferRewardMissionList(Player& player, const CJsonMessageBase& msg);
	static void STitleTakeOffOrWear(Player& player, const CJsonMessageBase& msg);
	static void STitleList(Player& player, const CJsonMessageBase& msg);
	static void STemp_AcceptMainTaskTargetInfo(Player& player, const CJsonMessageBase& msg);
	static void SSetPlayerHp(Player& player, const CJsonMessageBase& msg);
	static void SSetGuidState(Player& player, const CJsonMessageBase& msg);
	static void SRelayMessage(Player& player, const CJsonMessageBase& msg);
	static void SPlayerRockerState(Player& player, const CJsonMessageBase& msg);
	
	//static void SPlayerChangeScene(Player& player, const CJsonMessageBase& msg);
	static void SPing(Player& player, const CJsonMessageBase& msg);
	static void SOpenMissionDialog(Player& player, const CJsonMessageBase& msg);
	static void SOfferRewardMissionOperation(Player& player, const CJsonMessageBase& msg);
	static void SMissionMovePosition(Player& player, const CJsonMessageBase& msg);
	static void SMissionKillMonster(Player& player, const CJsonMessageBase& msg);
	static void SMissionDungeon(Player& player, const CJsonMessageBase& msg);
	static void SMissionCollect(Player& player, const CJsonMessageBase& msg);
	static void SLoginPlayerQuitGameNotify(Player& player, const CJsonMessageBase& msg);
	static void SHeal(Player& player, const CJsonMessageBase& msg);
	static void SGuideAskEvent(Player& player, const CJsonMessageBase& msg);
	static void SGmCommon(Player& player, const CJsonMessageBase& msg);
	static void SGetRewardPropsCommon(Player& player, const CJsonMessageBase& msg);
	static void SGeneralLuaMessage(Player& player, const CJsonMessageBase& msg);
	static void SFixed1024InfoByErea(Player& player, const CJsonMessageBase& msg);
	static void SClickNPC(Player& player, const CJsonMessageBase& msg);
	static void SAskMissionOfferList(Player& player, const CJsonMessageBase& msg);
	static void SAskMissionList(Player& player, const CJsonMessageBase& msg);
	static void SAskMissionDailyList(Player& player, const CJsonMessageBase& msg);
	static void SAskMissionComplete(Player& player, const CJsonMessageBase& msg);
	static void SAskMissionBoxInfo(Player& player, const CJsonMessageBase& msg);
	static void SPlayerAttack(Player& player, const CJsonMessageBase& msg);
	static void SAskForGuideInfo(Player& player, const CJsonMessageBase& msg);
	static void PlayerChangeName(Player& player, const CJsonMessageBase& msg);
	static int32_t OnMsgC2GEnterGameRequest(int32_t fd, const CJsonMessageBase& msg);


	static void SGeneralLuaMessageServer(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void DGPlayerRechangedNotify(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void L2GCreatePlayerRequest(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void D2GCreatePlayerResponse(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void L2GPlayerLoginRequest(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void L2GPlayerLoginCheckAccountRequest(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void D2GLoadPlayerResponse(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void MapPlayerLoginAgain(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void G2GateChangeMapConnect(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void SPlayerRevive(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void SyncHeroGame2Map(const common::CProxyHead& head, const CJsonMessageBase& msg);
	static void SPlayerChangeScene(const ::common::CProxyHead& head, const CJsonMessageBase& msg);

	void SendPlayerLoginResponse(int32_t playerId, int32_t msgid);

	void updatePlayerNewNameToDB(int32_t playerid, std::string& name);
	void updateOnlinePlayerCountToDB();
	void ExecSql(const char* sql, int split_id);

	void PlayerNumReportStart();
	void MapLayerLoginAgainByPlayer(Player* player);
private:
	CPlayerCountReportTimer player_num_timer_;
};

#endif